"use strict";
cc._RFpush(module, 'e4af3VPaaFMj4mnUg7+B9C6', 'AreaEffector');
// Box2D\Scripts\Effector\AreaEffector.js

var body;

cc.Class({
    'extends': cc.Component,

    editor: {
        requireComponent: Body
    },

    properties: {
        forceAngle: 0,
        forceMagnitude: 10
    },

    // use this for initialization
    onLoad: function onLoad() {
        body = this.getComponent('Body');
        body.bodyType = BodyType.STATIC;

        var callback = new CallbackEvent();
        callback.target = this;
        callback.componentName = this.__classname__;
        callback.functionName = 'onTargetEnter';
        body.onPreSolve = callback;
    },

    onTargetEnter: function onTargetEnter(contact) {
        // 关闭碰撞反应
        contact.setEnabled(false);

        var targetBody = contact.targetBody;
        var radian = this.forceAngle / 360 * 2 * Math.PI;
        var force = cc.pRotateByAngle(new cc.Vec2(0, 1), cc.Vec2.ZERO, -radian);
        force.x *= this.forceMagnitude;
        force.y *= this.forceMagnitude;
        targetBody.addForce(force);
    }
});

cc._RFpop();